#ifndef __FUNC_DEF_H__
#define __FUNC_DEF_H__

#include <stdint.h>


#define UDF01_EN          (1<<0)
#define UDF02_EN          (1<<1)
#define UDF03_EN          (1<<2)
#define UDF04_EN          (1<<3)
#define UDF05_EN          (1<<4)
#define UDF06_EN          (1<<5)
#define UDF07_EN          (1<<6)
#define UDF08_EN          (1<<7)
#define UDF09_EN          (1<<8)
#define UDF10_EN          (1<<9)
#define UDF11_EN          (1<<10)
#define UDF12_EN          (1<<11)
#define UDF13_EN          (1<<12)
#define UDF14_EN          (1<<13)
#define UDF15_EN          (1<<14)
#define UDF16_EN          (1<<15)

#define UDF_MAX_NUM       (16)


/* SYSBOOT内置功能开关 */ // mark1
#define FUNC_CRC_UDP_EN          (1<<0)
#define FUNC_RTC_CALIB_EN        (1<<1)
#define FUNC_CRC_UDF_EN          (1<<2)
#define FUNC_CRC_UDP_USR_CFG_EN  (1<<3)
#define FUNC_VERSION_OUTPUT_EN   (1<<4)

#define FUNC_CRC_UDP_DIS         (0<<0)
#define FUNC_RTC_CALIB_DIS       (0<<1)
#define FUNC_CRC_UDF_DIS         (0<<2)
#define FUNC_CRC_UDP_USR_CFG_DIS (0<<3)
#define FUNC_VERSION_OUTPUT_DIS  (0<<4)

typedef enum{
	eQSPI_FLASH_STD = 1,         /*0x0B*/
	eQSPI_FLASH_STD_SLOWCLK = 2, /*0x03*/
	eQSPI_FLASH_DUAL_OUTPUT = 3, /*dual output*/
	eQSPI_FLASH_DUAL_IO = 4,     /*dual io*/
	eQSPI_FLASH_QUAD_OUTPUT = 5, /*quad output*/
	eQSPI_FLASH_QUAD_IO = 6,     /*quad io*/
}eQSPI_FLASH_MODE;

typedef struct {
	uint32_t srcAddr;
	uint32_t dstAddr;
	uint16_t len;
	uint16_t crc;
}UDF_INFO;

typedef struct
{
	uint8_t  fw_version[32];
	/* 内置功能开关配置 */
	uint32_t funcEn;  // 见 mark1

	/*uart*/
	union{
		uint32_t baudrate;
		uint32_t use_uart;
	};
	
	uint16_t AtCmdDelay;
	/*rtc calib*/
	uint8_t rtcCailbClkCnt;
	/* qspi cfg*/
	eQSPI_FLASH_MODE qspiMode;

	/*watch dog timer*/
	uint32_t wdt_cnt;       
	
	/*io cfg*/
	uint32_t gpio_pmode;
	uint32_t gpio_pctrl_ue;
	uint32_t gpio_pctrl_re;
	uint32_t gpio_pmux0;
	uint32_t gpio_pmux1;

	/*opt data 、udf cfg*/
	uint32_t opt_data_len;// opt_data 长度
	uint16_t opt_data_crc;// opt_data 校验
	uint16_t udfEn;

	UDF_INFO udf01_info;
	UDF_INFO udf02_info;    
	UDF_INFO udf03_info;				
	UDF_INFO udf04_info;       
	UDF_INFO udf05_info;       
	UDF_INFO udf06_info;       
	UDF_INFO udf07_info;       
	UDF_INFO udf08_info;       
	UDF_INFO udf09_info;				
	UDF_INFO udf10_info;		
	UDF_INFO udf11_info;       
	UDF_INFO udf12_info;       
	UDF_INFO udf13_info;
	UDF_INFO udf14_info;       
	UDF_INFO udf15_info;       
	UDF_INFO udf16_info;

	/* ab area cfg*/
	uint32_t ab_area_offset;  // B区相对于A区的偏移
	uint32_t dl_flag;         // 0：非动态加载，其它：动态加载

	uint16_t crcLen;
	uint16_t crcVal;
}PARAM_FUNC;


#endif
